<?php defined('SYSPATH') or die('No direct script access.');

class Controller_Keywords extends Controller {

	public function action_index()
	{
		$data = new Model_Data_Keywords();
		$res_arr = $data->get_summary();
		// Displays "APPPATH/cache" rather than the real path
		echo Debug::vars($res_arr);
		echo "本期概况".$res_arr[0]['statdate'];
		$gg = array();
		$bd = array();
		$total = $res_arr[0]['total'];
		foreach($res_arr as $k=>$v){
			if($v['engine_id']==2){
				$gg['top3'] =  array(
					'num'=>$v['top3'],
					'per'=>$v['top3']/$total
				);
				$gg['top10'] =  array(
					'num'=>$v['top10'],
					'per'=>$v['top10']/$total
				);
				$gg['top50'] =  array(
					'num'=>$v['top50'],
					'per'=>$v['top50']/$total
				);
				$gg['after50'] =  array(
					'num'=>$v['after50'],
					'per'=>$v['after50']/$total
				);
			}else if($v['engine_id']==1){
				$bd['top3'] =  array(
					'num'=>$v['top3'],
					'per'=>$v['top3']/$total
				);
				$bd['top10'] =  array(
					'num'=>$v['top10'],
					'per'=>$v['top10']/$total
				);
				$bd['top50'] =  array(
					'num'=>$v['top50'],
					'per'=>$v['top50']/$total
				);
				$bd['after50'] =  array(
					'num'=>$v['after50'],
					'per'=>$v['after50']/$total
				);
			}
		}
		$summary = array(
			'gg'=>$gg,
			'bd'=>$bd,
		);
		echo Debug::vars($summary);
		
	}
}